import request from '@/assets/js/request';
import util from '@/assets/js/public';
import { getToken } from '@/assets/js/auth';

/// APPCode (待用)
const appCode = 'djzs';


/// 获取用户信息
export function getUserData(params) {
    console.log('获取用户信息时的名字是：' + params.userName);
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/getCurrentUser$sso',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'noAction': '1',
                'versionName': '2.7.92',
                'kv': {
                    'versionName': '2.7.92',
                    'versionCode': 2079200,
                    'appcode': appCode,
                    'currentUserCode': util.encrypt(params.userName),
                }
            }
        }
    )
}

/// 待办
export function getToDoList(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/'+'disByOrg$findMyToDo$api',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'currentUserCode': util.encrypt(params.userName),
                    'source': 'MOBILE',
                    'title': params.searchTitle,
                    'page': params.page,
                    'rows': params.rows,
                    'size': params.size,
                },
                'jsonName': 'appDecision',
                'appDecision': {
                  'page': params.page,
                  'rows': params.rows,
                  'tm': 'params.rows',
                }
            }
        }
    )
}

/// 已办
export function getDoneList(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
                'disByOrg$findMyDone$api',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'currentUserCode': util.encrypt(params.userName),
                    'source': 'MOBILE',
                    'title': params.searchTitle,
                    'page': params.page,
                    'rows': params.rows,
                    'size': params.size,
                },
            }
        }
    )
}

/// 草稿箱
export function getDraftList(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
                'distribute$findMyDraft$api',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'currentUserCode': util.encrypt(params.userName),
                    'source': 'MOBILE',
                    'title': params.searchTitle,
                    'page': params.page,
                    'rows': params.rows,
                    'size': params.size,
                },
            }
        }
    )
}

/// 我发布的
export function getWFQDList(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
                'distribute$findMyDistribute$api',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'currentUserCode': util.encrypt(params.userName),
                    'source': 'MOBILE',
                    'title': params.searchTitle,
                    'page': params.page,
                    'rows': params.rows,
                    'size': params.size,
                },
            }
        }
    )
}

/// 我发布的
export function getWFQDDetailList(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
                'disByOrg$findAllDisInfo$api',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'currentUserCode': util.encrypt(params.userName),
                    'source': 'MOBILE',
                    'page': params.page,
                    'rows': params.rows,
                    'size': params.size,
                },
                'jsonName': 'appDecision',
                'appDecision': {
                    'orderUuid': params.orderUuid
                }
                
            }
        }
    )
}

/// 派发列表
export function getPaifaList(params) {
  return request(
      {
          url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
              'distribute$findMyDistribute$api',
          contentType: 'application/json;charset=UTF-8',
          data: {
              'access_token': getToken(),
              'appCode': appCode,
              'currentUserCode': util.encrypt(params.userName),
              'versionName': '2.7.92',
              'kv': {
                  'currentUserCode': util.encrypt(params.userName),
                  'source': 'MOBILE',
                  'title': params.searchTitle,
                  'page': params.page,
                  'rows': params.rows,
                  'size': params.size,
              },
          }
      }
  )
}

/// 获取业务类型
export function findAllNoPage(params) {
  return request(
      {
          url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
              'workType$api$findAllNoPage',
          contentType: 'application/json;charset=UTF-8',
          data: {
              'access_token': getToken(),
              'appCode': appCode,
              'currentUserCode': util.encrypt(params.userName),
              'versionName': '2.7.92',
              'kv': {
                  'currentUserCode': util.encrypt(params.userName),
                  'source': 'MOBILE',
              },
          }
      }
  )
}
//获取部门信息
export function findPOrgAndCityOrg(params){
  return request(
    {
        url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +'group$findPOrgAndCityOrg$api',
        contentType: 'application/json;charset=UTF-8',
        data: {
            'access_token': getToken(),
            'appCode': appCode,
            'currentUserCode': util.encrypt(params.userName),
            'versionName': '2.7.92',
            'kv': {
                'currentUserCode': util.encrypt(params.userName),
                'source': 'MOBILE',
                'appcode': appCode,
            },
        }
    }
)
}
/// 第一议题 详情
export function getDYYTDetail(params) {
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +
                'UsStudy$api$getFormDetail',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'access_token': getToken(),
                'appCode': appCode,
                'currentUserCode': util.encrypt(params.userName),
                'versionName': '2.7.92',
                'kv': {
                    'source': 'MOBILE',
                    'pmInsId': params.pmInsId,
                    'processInstId': params.processInstId,
                    'workFlag': params.workFlag,
                    'currentUserCode': util.encrypt(params.userName),
                },
            }
        }
    )
}

///  提交
export function dyytSubmitProcess(params) {
    console.log('name:' + params.userName)
    var usrls = 'UsStudy$api$startSubmitProcess';
    return request(
        {
            url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + usrls + '?source=MOBILE',
            contentType: 'application/json;charset=UTF-8',
            data: {
                'currentUserCode': util.encrypt(params.userName),
                'access_token': getToken(),
                'appCode': appCode,
                'versionName': '2.7.92',
                'kv': {
                    'source': 'MOBILE',
                    'currentUserCode': util.encrypt(params.userName),
                    'workItemId': params.idcode.workItemId,
                    'outcome': params.outcome,
                    'processInstId': params.idcode.processInstId,
                    'location': params.idcode.location,
                    'outcomeName': params.outcomeName,
                },
                'jsonName': 'appDecision',
                'appDecision': params.flowParam
            }
        }
    )
}
///  保存
export function saveDraft(params) {
  return request(
      {
          url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + 'distribute$saveDraft$api' + '?source=MOBILE',
          contentType: 'application/json;charset=UTF-8',
          data: {
              'currentUserCode': util.encrypt(params.userName),
              'access_token': getToken(),
              'appCode': appCode,
              'versionName': '2.7.92',
              'kv': {
                  'source': 'MOBILE',
                  'currentUserCode': util.encrypt(params.userName),
              },
              'jsonName': 'appDecision',
              'appDecision': params.fromdetal
          }
      }
  )
}

export function djzsUploadProcessFiles(fd, params) {
    console.log('CCCCCCCCCC' + process.env.VUE_APP_UPFILE)
    return request({
        url: process.env.VUE_APP_URL + '/action/openapi/bps/common/uploadFile?pmInsType=A&pmInsTypePart=1&appcode=djzs&currentUserCode='
            + util.encrypt(params.userName) + '&access_token=' + getToken(),
        contentType: 'multipart/form-data',
        data: fd,
        catch: true
    })
}
//获取党建助手工单详情（草稿）
export function distribute(params){
  return request({
      url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + 'distribute$api$findById' + '?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          'access_token':getToken(),
          'appCode':appCode,
          'currentUserCode':util.encrypt(params.userName),
          'versionName':'2.7.92',
              'kv':{
                  'source':'MOBILE',
                  'currentUserCode':util.encrypt(params.userName),
                  'id':params.id,
              }
      }
  })
}

//获取党建助手工单详情
export function findById(params){
  return request({
      url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + 'disByOrg$api$findById' + '?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          'access_token':getToken(),
          'appCode':appCode,
          'currentUserCode':util.encrypt(params.userName),
          'versionName':'2.7.92',
              'kv':{
                  'source':'MOBILE',
                  'currentUserCode':util.encrypt(params.userName),
                  'id':params.id,
              }
      }
  })
}
//提交办理
export function submitOrder(params){
  return request({
      url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + 'distribute$submitOrder$api' + '?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          'access_token':getToken(),
          'appCode':appCode,
          'currentUserCode':util.encrypt(params.userName),
          'versionName':'2.7.92',
              'kv':{
                  'source':'MOBILE',
                  'currentUserCode':util.encrypt(params.userName),
                  'id':params.id,
              },
          'jsonName':'appDecision',
          'appDecision':params.fromdetal
      }
  })
}

//提交审核
export function submitInfo(params){
  return request({
      url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' + 'disByOrg$submitInfo$api' + '?source=MOBILE',
      contentType:'application/json;charset=UTF-8',
      data:{
          'access_token':getToken(),
          'appCode':appCode,
          'currentUserCode':util.encrypt(params.userName),
          'versionName':'2.7.92',
              'kv':{
                  'source':'MOBILE',
                  'currentUserCode':util.encrypt(params.userName),
                  'id':params.id,
              },
          'jsonName':'appDecision',
          'appDecision':params.fromdetal
      }
  })
}
//获取起草菜单
export function getMenuInfo(params){
  return request(
    {
        url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +'managerPerson$getMenuInfo$api',
        contentType: 'application/json;charset=UTF-8',
        data: {
            'access_token': getToken(),
            'appCode': appCode,
            'currentUserCode': util.encrypt(params.userName),
            'versionName': '2.7.92',
            'kv': {
                'currentUserCode': util.encrypt(params.userName),
                'source': 'MOBILE',
                'appcode': appCode,
              },
        }
    }
)
}

//获取部门信息接口2
export function findCityDeapartmentAndCountyCompany(params){
  return request(
    {
        url: process.env.VUE_APP_URL + '/action/openapi/bps/common/transmit/' +'group$findCityDeapartmentAndCountyCompany$api',
        contentType: 'application/json;charset=UTF-8',
        data: {
            'access_token': getToken(),
            'appCode': appCode,
            'currentUserCode': util.encrypt(params.userName),
            'versionName': '2.7.92',
            'kv': {
                'currentUserCode': util.encrypt(params.userName),
                'source': 'MOBILE',
                'appcode': appCode,
            },
        }
    }
)
}